package java流相关;

import java.util.Scanner;

/**
 * @author coderFu
 * @create 2022/3/4
 * 打印流和扫描流
 *
 * System.out.print() 等价与 PrintStream ps= System.out; ps.print();
 *
 */
public class PrintAndScannerStream {

    public static void main(String[] args) {

        String name = "小明";

        int age = 12;

        // 一般输出
        System.out.println("name: "+name +", age:"+age);

        // 打印流输出  % 此时为占位符

        String format = "name: %s, age: %d";
        Object[] data = {"小明", 12};

        System.out.printf(format,data);

        System.out.println();

        // 打印流简化 类似C_++
        System.out.printf("name: %s, age: %d",data);
        System.out.println();

        // 扫描流

        Scanner scanner = new Scanner("java可以提升人的逻辑思维能力" +
                ",一起来学习java吧");

        while(scanner.hasNextLine()){
            // 获取当前行输入的值
            String line = scanner.nextLine();
            System.out.println(line);
        }

        scanner.close();

    }
}
